﻿<script src="../../../processing.js"></script>
<canvas datasrc="resizeloop.pjs" width="200" height="200"></canvas>
<pre>
/* @pjs preload="ref_string.jpg" */
void setup() {
  size(200,200);
  PFont font;
  font = loadFont("Arial"); 
  textFont(font, 14);
  fill(32, 111, 175);
}

PImage img = loadImage("ref_string.jpg");
int w = 100;
int h = 100;
bool up = true;

void draw() {
  img.resize(w, h);
  background(255);
  image(img, 0, 0);
  text(int(FRAME_RATE) + "FPS", 10,15);
  
  if (w < 200 && up == true){
    w++;
    h++;
  } else if (w >= 200) {
    w = 199;
    h = 199;
    up = false;
  } else if (w < 50) {
    w = 50;
    h = 50;
    up = true;
  } else if (w < 200 && up == false) {
    w--;
    h--;
  } 
}
</pre>